package com.yunxiang.controller;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record;
import com.yunxiang.service.OrderService;

public class OrderController extends Controller{

	private OrderService orderService = new OrderService();
	/**
	 * 获取司机的订单记录列表
	 */
	public void getOrderByDriver(){
		String openId = getSessionAttr("openId");
		List<Record> list = orderService.getOrderByDriver(openId);
		
		JSONArray jArray = new JSONArray(0);
		for(int i=0;i<list.size();i++){
			JSONObject jObject = new JSONObject();
			Record order = list.get(i);
			Date date = order.get("DATE_KEY");
			jObject.put("date_key",date );
			jObject.put("gasstation_name", order.get("GASSTATION_NAME"));
			jObject.put("total_price", order.get("TOTAL_PRICE"));
			jArray.add(jObject);
		}
		renderJson(jArray.toString());
	}
}
